<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <% include("/view/console/common/css.html"){}	%>

 <title></title>
 </head>
 <body>
 <div class="zq-form">
 <form name="boWebNews_form"  id="boWebNews_form" class="form-horizontal" style="margin-bottom: 70px;">
   <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">是否发布</label>
 <div class="col-sm-6 col-xs-6">
 <div class="radio">
 <label><input checked='checked' auto_name='boWebNews_publish' type="radio"  name="publish" value="0"/>未发布</label>
 <label><input  auto_name='boWebNews_publish' type="radio"  name="publish" value="1"/>已发布</label>
  
 </div>
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">作者</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="author" id="author" class="form-control" check-type="" value='${boWebNews.author!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">来源</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="source" id="source" class="form-control" check-type="" value='${boWebNews.source!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">内容</label>
 <div class="col-sm-6 col-xs-6">
   <textarea name="content" id="content" placeholder="请输入内容" check-type="" class="layui-textarea">${boWebNews.content!}</textarea></div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">标题</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="title" id="title" class="form-control" check-type="" value='${boWebNews.title!}' >
 </div>
  </div>
 <div class="form-group">
 <label class="control-label col-sm-2 col-xs-2">新闻类型</label>
 <div class="col-sm-6 col-xs-6">
 	<select class="form-control" id="newsType"
 		name="newsType" check-type=" number">
 	<option selected='selected' value="1">普通新闻</option>
 </select>
 </div>
 </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">简介</label>
 <div class="col-sm-6 col-xs-6">
   <textarea name="intro" id="intro" placeholder="请输入内容" check-type="" class="layui-textarea">${boWebNews.intro!}</textarea></div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">关键字</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="keyword" id="keyword" class="form-control" check-type="" value='${boWebNews.keyword!}' >
 </div>
  </div>
  <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">封面</label>
 <div class="col-sm-3 col-xs-3">
   <span class="btn btn-success fileinput-button">
        <i class="glyphicon glyphicon-plus"></i>
        <span>添加</span>
  <input type="file" id="cover_file" class="form-control" value='${boWebNews.cover!}' >
  <input type="hidden" id="cover"  name="cover"class="form-control" value='${boWebNews.cover!}' >
    </span>
  <div id="cover_progress" class="progress">
   <div class="progress-bar progress-bar-success"></div>
  </div>
  </div>
   	<div class="col-sm-4 col-xs-4">
   	<img id="cover_file_show" src="${boWebNews.cover!}" style="width:100px;" alt="图片" class="img-rounded">
 </div>
 </div>
   <input type='hidden' name='id' id='id' value='${boWebNews.id!}'><input type='hidden' name='common_token' id='common_token' value='${common_token!}'>
 </form>
  <nav class="navbar navbar-default navbar-fixed-bottom" style="text-align: right">
    <a href="#" class="btn btn-success" style="margin:10px" id = "saveForm">保存 </a>
  </nav>
 </div>
 <% include("/view/console/common/js.html"){} 	%>
 <script>


layui.use(['layer','laydate'], function(){
  var laydate = layui.laydate;
    var layer = layui.layer;
/*开启表单验证*/
$("#boWebNews_form").validation();
          $('input[auto_name="boWebNews_publish"]').each(function(){
       if('${boWebNews.publish!}'==this.value){ 
             $(this).attr('checked','checked');
            }
           });
 var contentEdit = CKEDITOR.replace( 'content' );	$("#newsType").val("${boWebNews.newsType!}");
 	if('${boWebNews.newsType!}'==''){
 	    $("#newsType").val('1');
 	}
  consoleUploadAliImg('cover','');

$("#saveForm").click(function(){
saveZqForm();

})
  function saveZqForm(){
        if ($("#boWebNews_form").valid() == false) {
        return false;
        }
        var formObject=new Object();
        formObject.publish=($('input[name="publish"]:checked').val()==''?null:$('input[name="publish"]:checked').val()); 
 formObject.author=$('#author').val()==''?null:$('#author').val(); 
 formObject.source=$('#source').val()==''?null:$('#source').val(); 
 formObject.content=contentEdit.getData(); 
 formObject.cover=$('#cover').val()==''?null:$('#cover').val(); 
 formObject.title=$('#title').val()==''?null:$('#title').val(); 
 formObject.newsType=$('#newsType').val()==''?null:$('#newsType').val(); 
 formObject.intro=$('#intro').val()==''?null:$('#intro').val(); 
 formObject.keyword=$('#keyword').val()==''?null:$('#keyword').val(); 
 formObject.id=$('#id').val()==''?null:$('#id').val(); 
 
        var formObjectJson = JSON.stringify(formObject);
        $.post("/console/bo_web_news/save",
        {
        formObjectJson :formObjectJson,
        common_token :$("#common_token").val()
        }, function(data) {
        layer.alert(data.message, {skin: 'layui-layer-molv',closeBtn: 0 }, function(){
        parent.$("#boWebNews").bootstrapTable("refresh");
        parent.layer.closeAll();
        });

        });
    }
});

 </script>
 </body>
